<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp_lib/init.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>主页</title>
<jsp:include page="/WEB-INF/jsp/common/common.jsp" />
<jsp:include page="/WEB-INF/jsp_lib/extjs.jsp" />
<jsp:include page="add_customer.jsp" />
<script type="text/javascript">
	var comboxStore;
	var comboxCustomerStore;

	//设置ComboBox列表数据源参数
	comboxStore = Ext.create('Ext.data.Store', {
		fields : [ 'name', 'kid' ],
		remoteSort : true,
		autoLoad : true,
		pageSize : 10,
		sorters : {
			property : 'name',
			direction : 'ASC'
		},
		proxy : {
			type : "ajax",
			url : "${path}/cp/xyk/bank/list_data.htm",
			reader : {
				type : 'json',
				rootProperty : 'list',
				totalProperty : 'page.rowTotal'
			}
		}
	});

	comboxCustomerStore = Ext.create('Ext.data.Store', {
		fields : [ 'name', 'kid' ],
		remoteSort : true,
		autoLoad : true,
		pageSize : 10,
		sorters : {
			property : 'name',
			direction : 'ASC'
		},
		proxy : {
			type : "ajax",
			url : "${path}/cp/xyk/customer/list_data.htm",
			reader : {
				type : 'json',
				rootProperty : 'list',
				totalProperty : 'page.rowTotal'
			}
		}
	});
	var add_form_panel = Ext.create("Ext.form.Panel", {
		url : "${path}/cp/xyk/card/add.htm",
		buttonAlign : "center",
		bodyStyle : "padding: 5px;",
		defaultType : "textfield",
		layout : "form",
		items : [
				{
					xtype : 'combo',
					minChars : 1,
					labelStyle : "text-align:right;",fieldLabel : "客户",
					name : "card.customer_id",
					store : comboxCustomerStore,
					displayField : 'name',
					valueField : 'kid',
					hiddenName : 'card.customer_id',
					typeAhead : true,
					emptyText : '--请选择客户--',
					mode : 'remote',
					queryParam : 'srh_name',
					triggerAction : 'all',
					selectOnFocus : true,
					forceSelection : true,
					allowBlank : false
				},
				{
					xtype : "fieldcontainer",
					layout : "column",
					items : [ {
						labelStyle : "text-align:right;",fieldLabel : "卡号",
						name : "card.card_no",
						xtype : "textfield",
						allowBlank : false
					}, {
						xtype : 'combo',
						minChars : 1,
						labelStyle : "text-align:right;",fieldLabel : "银行",
						name : "card.bank_id",
						emptyText : '请选择银行',
						store : comboxStore,
						displayField : 'name',
						valueField : 'kid',
						hiddenName : 'card.bank_id',
						typeAhead : true,
						mode : 'remote',
						queryParam : 'srh_name',
						triggerAction : 'all',
						selectOnFocus : true,
						forceSelection : true,
						allowBlank : false
					}, {
						labelStyle : "text-align:right;",fieldLabel : "开卡日期",
						name : "card_date",
						xtype : "datefield",
						format : "Y-m-d",
						allowBlank : false
					} ]
				},
				{
					xtype : "fieldcontainer",
					layout : "column",
					items : [ {
						labelStyle : "text-align:right;",fieldLabel : "固定额度",
						name : "card.money_max",
						xtype : "numberfield",
						allowBlank : false
					}, {
						labelStyle : "text-align:right;",fieldLabel : "临时额度",
						name : "card.money_max_temp",
						xtype : "numberfield",
						allowBlank : false
					}, {
						labelStyle : "text-align:right;",fieldLabel : "超限额度",
						name : "card.money_max_super",
						xtype : "numberfield",
						allowBlank : false
					} ]
				},
				{
					xtype : "fieldcontainer",
					layout : "column",
					items : [ {
						labelStyle : "text-align:right;",fieldLabel : "附属卡",
						name : "card.is_other_card",
						xtype : "combo",
						mode : 'local',
						value : '无',
						store : new Ext.data.SimpleStore({
							fields : [ 'value', 'text' ],
							data : [ [ '有', '有' ], [ '无', '无' ] ]
						})
					}, {
						labelStyle : "text-align:right;",fieldLabel : "逾期情况",
						name : "card.is_past",
						xtype : "combo",
						mode : 'local',
						value : '无',
						store : new Ext.data.SimpleStore({
							fields : [ 'value', 'text' ],
							data : [ [ '有', '有' ], [ '无', '无' ] ]
						})
					}, {
						labelStyle : "text-align:right;",fieldLabel : "逾期次数",
						name : "card.past_cnt",
						xtype : "numberfield"
					} ]
				},
				{
					xtype : "fieldcontainer",
					layout : "column",
					items : [
							{
								labelStyle : "text-align:right;",fieldLabel : "卡内余额",
								name : "card.money_remain",
								xtype : "numberfield",
								allowBlank : false
							},
							{
								labelStyle : "text-align:right;",fieldLabel : "卡种",
								name : "card.card_type",
								xtype : "combo",
								mode : 'local',
								emptyText : '--请选择--',
								store : new Ext.data.SimpleStore(
										{
											fields : [ 'value', 'text' ],
											data : [ [ '普卡', '普卡' ],
													[ '金卡', '金卡' ],
													[ '白金卡', '白金卡' ],
													[ '钻石卡', '钻石卡' ] ]
										})
							} ]
				}, {
					xtype : "fieldcontainer",
					layout : "column",
					items : [ {
						labelStyle : "text-align:right;",fieldLabel : "还款方式",
						name : "card.back_type",
						xtype : "combo",
						mode : 'local',
						value : '转账',
						store : new Ext.data.SimpleStore({
							fields : [ 'value', 'text' ],
							data : [ [ '转账', '转账' ], [ '现金', '现金' ] ]
						})
					}, {
						labelStyle : "text-align:right;",fieldLabel : "有效期",
						name : "card_end_date",
						xtype : "datefield",
						format : "Y-m",
						allowBlank : false
					}, {
						labelStyle : "text-align:right;",fieldLabel : "账单投递方式",
						name : "card.bill_type",
						xtype : "combo",
						mode : 'local',
						value : '电子账单',
						store : new Ext.data.SimpleStore({
							fields : [ 'value', 'text' ],
							data : [ [ '电子账单', '电子账单' ], [ '纸质账单', '纸质账单' ] ]
						})
					} ]
				}, {
					xtype : "fieldcontainer",
					layout : "column",
					items : [ , {
						labelStyle : "text-align:right;",fieldLabel : "账单日",
						name : "card.bill_day",
						xtype : "numberfield",
						allowBlank : false
					}, {
						labelStyle : "text-align:right;",fieldLabel : "最后还款日",
						name : "card.bill_back_day",
						xtype : "numberfield",
						allowBlank : false
					} ]
				}, {
					xtype : "fieldcontainer",
					layout : "column",
					items : [ {
						labelStyle : "text-align:right;",fieldLabel : "查询密码",
						name : "card.pwd_query",
						xtype : "textfield"
					}, {
						labelStyle : "text-align:right;",fieldLabel : "交易密码",
						name : "card.pwd_pay",
						xtype : "textfield"
					} ]
				}, {
					labelStyle : "text-align:right;",fieldLabel : "备注",
					name : "card.note",
					xtype : "textareafield"
				}

		],
		buttons : [ {
			text : "保存",
			formBind : true, //only enabled once the form is valid
			disabled : true,
			handler : function() {
				var form = this.up("form").getForm();
				if (form.isValid()) {
					form.submit({
						waitMsg : "保存中...",
						success : function(form, action) {
							Ext.Msg.alert("提示", action.result.tip.msg);
							add_form_panel_win.close();
							//dataStore.load();
						},
						failure : function(form, action) {
							Ext.Msg.alert("提示", action.result.tip.msg);
						}
					});
				}
			}
		} ]
	});

	var add_form_panel_win = Ext.create("Ext.Window", {
		title : "信用卡添加",
		closeAction : "hide",
		items : add_form_panel
	});

	function myAdd() {
		add_form_panel.getForm().reset();
		add_form_panel_win.show();
	}
</script>

<script type="text/javascript">
	var titles = [ "", "-->账单提醒", "-->还款提醒", "客户管理", "信用卡管理", "一键办卡", "一键提额",
			"" ];
	var codes = [ "020020", "020025", "020030", "020010", "020020", "list_bk",
			"list_te", "" ];
	var urls = [ "myAdd", "/cp/xyk/doit/zd/list.htm", "/cp/xyk/doit/list.htm",
			"myAddCust", "/cp/xyk/card/all/list.htm",
			"/cp/xyk/bank/info/list_bk.htm", "/cp/xyk/bank/info/list_te.htm",
			"" ];

	function gotoMain(index) {
		var url = urls[index];
		if (url == "") {
			return;
		}

		if (url == "myAdd") {
			myAdd();
			return;
		}
		if (url == "myAddCust") {
			myAddCust();
			return;
		}

		var title = titles[index];
		var code = codes[index];

		window.parent.openTab(title, code, url);

	}
</script>
<style type="text/css">
li {
	float: left;
	list-style: none;
	margin: 5px;
}
img {
	width: 90px;
	height: 90px;
}
</style>
</head>
<body>
	<div id="content">
		<ul>
			<li><a href="javascript:gotoMain(3)"> <img
					src="${path}/style/cp/img/logo/btn3_1.png" />
			</a></li>
			<li><a href="javascript:gotoMain(0)"> <img
					src="${path}/style/cp/img/logo/btn1.png" />
			</a></li>
			<li><a href="javascript:gotoMain(1)"> <img
					src="${path}/style/cp/img/logo/btn2.png" />
			</a></li>
			<li><a href="javascript:gotoMain(2)"> <img
					src="${path}/style/cp/img/logo/btn3.png" />
			</a></li>

			<li><a href="javascript:gotoMain(4)"> <img
					src="${path}/style/cp/img/logo/btn3_2.png" />
			</a></li>

			<li><a href="javascript:gotoMain(5)"> <img
					src="${path}/style/cp/img/logo/btn4.png" />
			</a></li>
			<li><a href="javascript:gotoMain(6)"> <img
					src="${path}/style/cp/img/logo/btn5.png" />
			</a></li>

			<li><a
				href="http://xyk.nafuy.com/art_list.htm?cate=线上贷款"
				target="_blank"> <img src="${path}/style/cp/img/logo/btn7.png" />
			</a></li>
			<li><a
				href="http://xyk.nafuy.com/art_list.htm?cate=最新技术"
				target="_blank"> <img src="${path}/style/cp/img/logo/btn8.png" />
			</a></li>

			<li><a href="javascript:gotoMain(7)"> <img
					src="${path}/style/cp/img/logo/btn6.png" />
			</a></li>
		</ul>

	</div>
</body>
</html>